/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class emailUtilityClass_Test 
{

    static testMethod void testsendEmail_test() {
        List<String> recepients=new String[]{'test@test.com','test2@test.com'};
        emailUtilityClass.sendTextEmail(recepients,'Test method', 'This is to test the sendTextNotificationEmail method');
        emailUtilityClass.sendHTMLEmail(recepients,'Test method', 'This is to test the sendTextNotificationEmail method');
    } 
    
    static testMethod void testsendEmailNoReceipients_test() {
        List<String> recepients=null;
        emailUtilityClass.sendTextEmail(recepients,'Test method', 'This is to test the sendTextNotificationEmail method');
        
        recepients=new List<String>();
        emailUtilityClass.sendHTMLEmail(recepients,'Test method', 'This is to test the sendTextNotificationEmail method');
    }
    
    static testMethod void testsendEmailWithAttachment_test() {
        List<String> recepients=new String[]{'test@test.com','test2@test.com'};
        List<Attachment> stdAttachments = new List<Attachment>();
        Attachment a = new Attachment();
        a.Name = 'Test';
        a.Body = EncodingUtil.base64Decode('Test Body');
        stdAttachments.add(a);
        emailUtilityClass.sendEmailWithStandardAttachments(recepients,'Test method', 'This is to test the sendTextNotificationEmail method',false,stdAttachments);
    }
    
    static testMethod void testsendEmailWithAttachmentIDs_test() {
        List<String> recepients=new String[]{'test@test.com','test2@test.com'};
        List<ID> stdAttachments = new List<ID>();
        
        //Account Object Record...
        Account accountObject1 = new Account();
        accountObject1.Name = 'Test Account';
        //accountObject1.LicenseNumber__c = serialObject.id;
        accountObject1.License_Application_Step__c = 'Archived';
        accountObject1.Activity__c = 'Trading - One Activity';
        accountObject1.License_Issue_Date__c = system.today().addyears(-2);
        accountObject1.Master_Account_Flag__c = true;
        accountObject1.License_Application_Type__c = 'Renewal Additional';
        accountObject1.License_Expiry_Date__c = System.Today().addYears(-1);
        accountObject1.Renew_Additional_Type__c = 'Renew With Change Location';
        
        insert accountObject1;
        
        Attachment a = new Attachment();
        a.ParentId = accountObject1.Id;
        a.Name = 'Test';
        a.Body = EncodingUtil.base64Decode('Test Body');
        insert a;
        stdAttachments.add(a.Id);
        emailUtilityClass.sendEmailWithStandardAttachments(recepients,'Test method', 'This is to test the sendTextNotificationEmail method',false,stdAttachments);
    }

    private static testmethod void testIsNotValidEmailAddress(){
        //test:  global static Boolean isNotValidEmailAddress(String str)
        System.assertEquals(true,emailUtilityClass.isNotValidEmailAddress(null));
        System.assertEquals(true,emailUtilityClass.isNotValidEmailAddress('  '));
        System.assertEquals(true,emailUtilityClass.isNotValidEmailAddress('x'));
        System.assertEquals(true,emailUtilityClass.isNotValidEmailAddress('x@'));
        System.assertEquals(true,emailUtilityClass.isNotValidEmailAddress('x@x'));
        System.assertEquals(false,emailUtilityClass.isNotValidEmailAddress('x@x.x'));
    }
}